<%- include header.ejs%>


<div style="background-color: white;border: 1px solid #ffffff;-moz-border-radius: 10px;-webkit-border-radius: 10px;margin-top: 70px;padding: 3%">
    <div style="width: 200px;height:250px;float:left;border: 1px dotted #9f9d93;position: relative;">
        <img id="img_poster"  src="" style="width: 200px;height: 250px">
        <div class="circular" style="position: absolute;top:90px;left:25px;z-index:10;text-align:center;width:130px;height: 40px;background-color: #d77a03;">
            <h3 style="color: white;line-height: 20px">海报预览</b></h3>
        </div>
        <div class="file-box" style="margin-top: 20px">
            <form action="" id="uploadPoster" method="post" enctype="multipart/form-data">
                <input type='text' name='textfield' id='textfield' class='txt' style="margin-bottom: 0px"/>
                <input type='button' class='btn' value='浏览...' />
                <input type="file" name="file" class="file" id="fileToUpload" size="28" onchange="document.getElementById('textfield').value=this.value" />
                <input type="submit" name="submit" class="btn" value="上传" onclick="return ajaxFileUpload();"/>
            </form>

        </div>
    </div>
    <form onsubmit="return checkueditor();" class="form-horizontal registerform" action="" method="post">
    <div style="width: 50%;float: left;margin-left: 8%">

            <fieldset>

                <div>
                    <div class="control-group">
                        <table>
                            <tr>
                                <td>
                                    <label class="control-label" style="font-size: large"><span class="need" style="width:10px;">*</span > 活动名称</label>
                                </td>
                                <td>
                                    <input type="text" class="inputxt"  name="theme" datatype="*3-18" errormsg="名称至少3个字符,最多18个字符！">
                                </td>
                                <td style="padding-top: 10px">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="control-group">
                        <table>
                            <tr>
                                <td>
                                    <label class="control-label" style="font-size: large"><span class="need" style="width:10px;">*</span> 活动时间</label>
                                </td>
                                <td>
                                    <input type="text" class="inputxt"  name="activeDate" datatype="*6-30" errormsg="yyyy-MM-dd hh:00||hh:00-hh:00！">
                                </td>
                                <td style="padding-top: 10px">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="control-group">
                        <table>
                            <tr>
                                <td>
                                    <label class="control-label" style="font-size: large"><span class="need" style="width:10px;">*</span> 活动地点</label>
                                </td>
                                <td>
                                    <input type="text" class="inputxt"  name="addr" datatype="*3-20" errormsg="请输入正确的地点！">
                                </td>
                                <td style="padding-top: 10px">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="control-group">
                        <table>
                            <tr>
                                <td>
                                    <label class="control-label" style="font-size: large"><span class="need" style="width:10px;">* </span>主办方&nbsp;&nbsp;&nbsp;</label>
                                </td>
                                <td>
                                    <input type="text" class="inputxt"  name="sponsor" datatype="*3-20" errormsg="主办方为3-20个字符！">
                                </td>
                                <td style="padding-top: 10px">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="control-group">
                        <table>
                            <tr>
                                <td>
                                    <label class="control-label" style="font-size: large"><span class="need" style="width:10px;">*</span> 活动语言</label>
                                </td>
                                <td>
                                    <select name="language" datatype="*" nullmsg="请选择语言！" errormsg="请选择语言！">
                                        <option value="">请选择</option>
                                        <% plateDatas.forEach(function(plateData,index){%>
                                        <option value="<%- plateData.platename%>"><%- plateData.platename%></option>
                                        <% })%>
                                    </select>
                                </td>
                                <td style="padding-top: 10px">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="control-group">
                        <table>
                            <tr>
                                <td>
                                    <label class="control-label" style="font-size: large"><span class="need" style="width:10px;">*</span> 活动费用</label>
                                </td>
                                <td>
                                    <input type="text" class="inputxt"  name="cost" datatype="n1-4" errormsg=金额只能为0-1000的数字>
                                </td>
                                <td style="padding-top: 10px">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>


            </fieldset>

    </div>

    <div style="clear: both"></div>
    <div style="-webkit-border-radius:10px 10px 0px 0px;clear: both;background: #fd9b05;height: 40px;text-align: center;width: 15%;margin-top: 20px">
        <h3 style="color: #9e9e9e"><b>活动详情</b></h3>
    </div>
    <div style="height: 280px;background: #f2f2f2;-webkit-border-radius:0px 10px 10px 10px;padding: 20px">
        <script id="uecontainer" name="discribe" type="text/plain"></script>
    </div>
    <div style="text-align: center;margin-top: 30px">
        <button type="submit" class="btn btn-warning">发布活动</button>
    </div>
    </form>
</div>



<%- include footer.ejs%>
<script type="text/javascript">
    var ue = UE.getEditor('uecontainer',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:171,
        saveInterval:60000
    });
    function checkueditor(){

        //alert(UE.getEditor('container').getContent().replace(/[\s\r\n]/g,'').length)
        if(UE.getEditor('uecontainer').getContent().replace(/<.*?>/g,'').length<50){
            alert('详细信息输入字符不足50个,请重新输入')
            return false;
        }
        return true;
    }
</script>
<script type="text/javascript">
    $(function(){
        //$(".registerform").Validform();  //就这一行代码！;

        $(".registerform").Validform({
            tiptype:2
        })


    })
    function ajaxFileUpload() {

        $.ajaxFileUpload({
            url : '/uploadPoster',// servlet请求路径
            secureuri : false,
            fileElementId : 'fileToUpload',// 上传控件的id
            dataType:'text',
            success : function(data) {
                //alert(data);
                //alert(data.replace(/<.*?>/ig,''));

                if(data.indexOf('url')<0){
                    alert(data.replace(/<.*?>/ig,''));
                }
                eval("var jsobjjson="+data.replace(/<.*?>/ig,''));
                //alert(decodeURIComponent(jsobjjson.url))

                if(jsobjjson.state=='上传成功'){
                    //alert('111')
                    $("#img_poster").attr("src",decodeURIComponent(jsobjjson.url));
                }
            },
            error : function(data, status, e) {
                alert('上传出错');
            }
        })

        return false;

    }
</script>
